package gov.nasa.anml.lifted;

import gov.nasa.anml.PDDL;
import gov.nasa.anml.State;
import gov.nasa.anml.PDDL.Expression;
import gov.nasa.anml.utility.SimpleObject;
import gov.nasa.anml.utility.SimpleString;

public abstract class IdentifierImp<L,R extends SimpleObject<? super R>> extends ExpressionImp<L,R> implements Identifier<L,R> {
	
	// should delete the following three to force subclasses to implement.
	public History<R> storage(State p, State c) {
		return null;
	}

	public L value(State s) {
		return null;
	}

	public boolean apply(State p, int contextID, State c) {
		return false;
	}

	public int id;
	public SimpleString name;
	
	public IdentifierImp() {
		name = null;
		id = -1;
	}
	
	public IdentifierImp(SimpleString n) {
		name = n;
		id=-1;
	}
	
	public IdentifierImp(SimpleString n, int i) {
		name = n;
		id = i;
	}

	public final Identifier<L,R> id(int id) {
		this.id = id;
		return this;
	}

	public final int id() {
		return this.id;
	}

	public final SimpleString name() {
		return this.name;
	}

	public final Identifier<L,R> name(SimpleString name) {
		this.name = name;
		return this;
	}
	
	// ids will be chronological within groups of same code identifiers
	// names will be alphabetical
	public int compareTo(Identifier<L,R> i) {
		return id - i.id();
		//return name.compareTo(i.name());
	}
	
	public boolean equals(Identifier<L,R> i) {
		if (id != i.id())
			return false;
		/*
		if (SimpleString.compareTo(name,i.name()) != 0)
			return false;
		*/
		return true;
	}

}
